home *** CD-ROM | disk | FTP | other *** search
- /* FILE: ShowVars.c
- Displays up to 10 sets of variable labels and values. */
- #include "PStrLib.h"
-
- ShowVars(count, varLabel, varType, varPtr)
- int count; /* # of {varLabel,varType,varPtr} sets */
- char *varLabel; /* string label for variable */
- int varType; /* type of variable*/
- char *varPtr; /* pointer to variable */
- {
- auto char **lh = &varLabel; /* Ptr to 1st varLabel */
- auto int *tp = &varType; /* Ptr to 1st varType */
- auto char **vh = &varPtr; /* Ptr to 1st varPtr */
- auto char *sp;
- auto Str255 s;
- auto Rect wRect;
- auto WindowPtr wp, savedPort;
- auto int y = 5;
-
- if (count > 0) {
- if (count > 10)
- count = 10; /* max number of arg. sets */
- GetPort(&savedPort);
- wRect.top = 45;
- wRect.left = 72;
- wRect.bottom = count * 20 + wRect.top + 45;
- wRect.right = 440;
- wp = NewWindow(NIL, &wRect, NIL, TRUE, dBoxProc, -1L, FALSE, NIL);
- SetPort(wp);
- while (--count >= 0) {
- if (*tp == PSTR)
- sp = *vh;
- else if (*tp == BOOL)
- sp = **(Boolean **)vh ? "\pTRUE" : "\pFALSE";
- else {
- sp = (char *)s;
- Num2PStr(*tp, *vh, sp, DEC, (*tp >= CINT ? 0 : 6));
- }
- MoveTo(30, y += 20);
- if (*lh && **lh) { /* Length of varLabel > 0? */
- DrawString(*lh);
- DrawString("\p = ");
- }
- DrawString(sp);
- /*
- Incr. Ptr's 10 bytes each pass so they'll
- point to the next set of arg.s on the stack.
- */
-
- lh = (char **)((char *)lh + 10);
- tp += 5;
- vh = (char **)((char *)vh + 10);
- }
- MoveTo(30, wRect.bottom - wRect.top - 10);
- DrawString("\pClick Mouse Button to Continue...");
- while (!Button()); /* Wait for a mouse down event */
- DisposeWindow(wp);
- SetPort(savedPort);
- }
- }